/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.unal.bioingenium.kbmed.services.client;

import co.edu.unal.bioingenium.kbmed.config.Configuration;
import co.edu.unal.bioingenium.kbmed.knowledge.vo.DescriptorData;
import co.edu.unal.bioingenium.kbmed.mapping.services.api.MappingService;
import co.edu.unal.bioingenium.kbmed.mapping.services.api.impl.MappingServiceImpl;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Alejandro Riveros Cruz
 */
public class MappingClient {

    public static void main(String[] args) {
        try {
            MappingService mappingService = new MappingServiceImpl(Configuration.MAPPING_SERVICE_ENDPOINT);
            String key = mappingService.doMapping("guitarra flauta");


            Set<String> sentences = null;
            while (!mappingService.isProcessed(key)) {
                Thread.sleep(10);
            }
            sentences = mappingService.getSentences(key);
            int i = 0;
            for (String sentence : sentences) {
                System.out.println(sentence);
                List<DescriptorData> concepts = mappingService.getConcepts(key, sentence);
                for (DescriptorData descriptorData : concepts) {
                    System.out.println(descriptorData.getConceptId() + " - " + descriptorData.getTerm() + " - " + descriptorData.getCategory());
                }

            }
        } catch (InterruptedException ex) {
            Logger.getLogger(MappingClient.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
